package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo5 {
    public static void main(String[] args) throws Exception {
        Person p = new Person();
        p.say("hello");


        Class cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();
        Method m = cls.getMethod("say", String.class);
        m.invoke(obj,"大家好！我是张麒，晚上给大家跳支舞！");


        Class cls2 = Class.forName("reflect.Person");
        Object obj2 = cls2.newInstance();
        Method m2 = cls2.getMethod("say", String.class,int.class);
        m2.invoke(obj2,"大家好！我是张麒，晚上给大家跳支舞！",5);
    }
}
